﻿using System.Collections.Generic;

namespace MachinaAurum.DempsterShafer
{
    public class Evidence
    {
        private IEnumerable<ISet<int>> PowerSet;
        Dictionary<ISet<int>, double> Masses = new Dictionary<ISet<int>, double>(new SetComparer<int>());

        public IEnumerable<ISet<int>> States { get { return Masses.Keys; } }

        internal Evidence(IEnumerable<ISet<int>> PowerSet)
        {
            this.PowerSet = PowerSet;
        }

        public void SetMass(double mass, params int[] states)
        {
            var set = new SortedSet<int>(states);
            Masses[set] = mass;
        }

        public double GetMass(params int[] states)
        {
            var set = new SortedSet<int>(states);
            return GetMass(set);
        }

        public double GetMass(ISet<int> state)
        {
            double mass = 0.0;

            if (Masses.TryGetValue(state, out mass))
            {
                return mass;
            }
            else
            {
                return 0.0;
            }
        }
    }
}
